//
//  UIColor+Extension.h
//  Extision
//
//  Created by 岳道峰 on 2017/4/18.
//  Copyright © 2017年 hao. All rights reserved.
//

#import <UIKit/UIKit.h>

UIKIT_EXTERN UIColor *UIColorWithHexRGB(uint32_t rgbValue);
UIKIT_EXTERN UIColor *UIColorWithHexRGBA(uint32_t rgbaValue);

UIKIT_EXTERN UIColor *UIColorWithRGBA(uint8_t r, uint8_t g, uint8_t b, CGFloat a);
UIKIT_EXTERN UIColor *UIColorWithRGB(uint8_t r, uint8_t g, uint8_t b);

#define ColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

#define ColorRGB(r, g, b)     ColorRGBA((r), (g), (b), 1)

#define Color(v)              ColorRGB((v), (v), (v))

#define HexColor(rgbValue)    [UIColor colorWithRGB:(rgbValue)]

/** 随机颜色 */
#define RandomColor ColorRGB(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))

/**
 如果需要更多色彩空间的转换 (CIEXYZ,Lab,YUV...),
 看这个repo: https://github.com/ibireme/yy_color_convertor
 */
@interface UIColor (Extension)


#pragma mark - Create a UIColor Object
///=============================================================================
/// @name Creating a UIColor Object
/**
 Creates and returns a color object using the hex RGB color values.
 
 @param rgbValue  The rgb value such as 0x66ccff.
 
 @return          The color object. The color information represented by this
 object is in the device RGB colorspace.
 */
+ (UIColor *)colorWithRGB:(uint32_t)rgbValue;

/**
 Creates and returns a color object using the hex RGBA color values.
 
 @param rgbaValue  The rgb value such as 0x66ccffff.
 
 @return           The color object. The color information represented by this
 object is in the device RGB colorspace.
 */
+ (UIColor *)colorWithRGBA:(uint32_t)rgbaValue;

/**
 Creates and returns a color object using the specified opacity and RGB hex value.
 
 @param rgbValue  The rgb value such as 0x66CCFF.
 
 @param alpha     The opacity value of the color object,
 specified as a value from 0.0 to 1.0.
 
 @return          The color object. The color information represented by this
 object is in the device RGB colorspace.
 */
+ (UIColor *)colorWithRGB:(uint32_t)rgbValue alpha:(CGFloat)alpha;


/**
 Returns the rgb value in hex.
 @return hex value of RGB,such as 0x66ccff.
 */
- (uint32_t)rgbValue; 

/**
 Returns the rgba value in hex.
 
 @return hex value of RGBA,such as 0x66ccffff.
 */
- (uint32_t)rgbaValue;

@end
